﻿<UserControl x:Class="TestCaseManagerApp.Views.SharedStepsInitialView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:local="clr-namespace:TestCaseManagerApp.Views"
             xmlns:entities="clr-namespace:TestCaseManagerCore.BusinessLogic.Entities;assembly=TestCaseManagerCore"       
             mc:Ignorable="d" Loaded="TestCaseInitialView_Loaded">
    <Grid>
        <Grid.CommandBindings>
            <CommandBinding Command="{x:Static local:TestCasesInitialView.EditCommand}" Executed="btnEdit_Click"/>
            <CommandBinding Command="{x:Static local:TestCasesInitialView.DuplicateCommand}" Executed="btnDuplicate_Click"/>
            <CommandBinding Command="{x:Static local:TestCasesInitialView.NewCommand}" Executed="btnNew_Click"/>
        </Grid.CommandBindings>
        <ProgressBar Name="progressBar" Minimum="0" Maximum="1" Height="16" IsIndeterminate="True" Margin="0,0,0,16" />

        <Grid Name="mainGrid" Visibility="Hidden">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1.5*"/>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Horizontal" Grid.ColumnSpan="2">
                <TextBlock Text="Search Shared Steps" Margin="10,0,10,30" Height="Auto" Width="Auto" FontWeight="Bold" FontSize="26" HorizontalAlignment="Left" Grid.Row="0"/>
            </StackPanel>

            <StackPanel Orientation="Vertical" Grid.Row="1" >
                <StackPanel Orientation="Vertical" Margin="10,0,0,30" Grid.Column="0" Grid.ColumnSpan="3">
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                        <Button Name="btnEdit1" Content="_Edit" Margin="0,0,10,0" Height="30" Width="90" VerticalAlignment="Center" Click="btnEdit_Click"/>
                        <Button Name="btnDuplicate1" Content="_Duplcate"  Margin="30,0,10,0" Height="30" Width="90" VerticalAlignment="Center" Click="btnDuplicate_Click"/>
                        <Button Name="btnNew1" Content="_New"  Margin="30,0,10,0" Height="30" Width="90" VerticalAlignment="Center" Click="btnNew_Click"/>
                        <Button Name="btnFindReferences1" Content="Find References"  Margin="30,0,10,0" Height="30" Width="Auto" VerticalAlignment="Center" Click="btnFindReferences_Click"/>
                        <Button Name="btnChangeTestCases1" Content="Change Test Cases"  Margin="30,0,10,0" Height="30" Width="Auto" VerticalAlignment="Center" Click="btnChangeTestCases_Click"/>
                    </StackPanel>
                </StackPanel>
                <Grid Grid.Column="0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="1.15*" />
                        <ColumnDefinition Width="6*" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="2*" />
                    </Grid.ColumnDefinitions>
                    <TextBox Name="tbIdFilter" Text="{Binding InitialViewFiltersSharedSteps.IdFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TabIndex="0" Margin="10,0,0,10" Height="25"
                             Grid.Column="0" GotFocus="tbIdFilter_GotFocus" LostFocus="tbIdFilter_LostFocus" KeyUp="tbIdFilter_KeyUp" />
                    <TextBox Name="tbTitleFilter" Text="{Binding InitialViewFiltersSharedSteps.TitleFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TabIndex="1" Margin="10,0,0,10" Height="25"
                             Grid.Column="1" GotFocus="tbTitleFilter_GotFocus" LostFocus="tbTitleFilter_LostFocus" KeyUp="tbTitleFilter_KeyUp"/>
                    <TextBox Name="tbPriorityFilter" Margin="10,0,0,10" Height="25" Text="{Binding InitialViewFiltersSharedSteps.PriorityFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TabIndex="3"
                             GotFocus="tbPriorityFilter_GotFocus"  LostFocus="tbPriorityFilter_LostFocus" KeyUp="tbPriorityFilter_KeyUp" Grid.Column="2" />
                    <TextBox Name="tbAssignedToFilter" Margin="10,0,10,10" Height="25" Text="{Binding InitialViewFiltersSharedSteps.AssignedToFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TabIndex="4"
                             GotFocus="tbAssignedToFilter_GotFocus"  LostFocus="tbAssignedToFilter_LostFocus"  KeyUp="tbAssignedToFilter_KeyUp"  Grid.Column="3"/>
                </Grid>
            </StackPanel>

            <DataGrid ItemsSource="{Binding Path=ObservableSharedSteps}" AutoGenerateColumns="False" Name="dgSharedSteps" Grid.Row="2" Grid.Column="0" 
                      IsReadOnly="True" SelectionMode="Single" SelectionUnit="FullRow" TabIndex="4" SelectedValue="{Binding Path=SelectedSharedStep, Mode=TwoWay}"
                      SelectedCellsChanged="dgSharedSteps_SelectedCellsChanged" Margin="{StaticResource SplitRight}">
                <DataGrid.ItemContainerStyle>
                    <Style TargetType="{x:Type DataGridRow}" BasedOn="{StaticResource {x:Type DataGridRow}}">
                        <EventSetter Event="MouseDoubleClick" Handler="dgSharedSteps_MouseDoubleClick" />
                        <EventSetter Event="PreviewKeyDown" Handler="dgSharedSteps_KeyDown" />
                    </Style>
                </DataGrid.ItemContainerStyle>

                <DataGrid.ContextMenu>
                    <ContextMenu>
                        <MenuItem Name="dgSharedStepsContextItemPreview" Command="{x:Static local:TestCasesInitialView.PreviewCommand}" Header="Preview"/>
                        <MenuItem Name="dgSharedStepsContextItemEdit" Command="{x:Static local:TestCasesInitialView.EditCommand}" Header="Edit"/>
                        <MenuItem Name="dgSharedStepsContextItemDuplicate" Command="{x:Static local:TestCasesInitialView.DuplicateCommand}" Header="Duplicate"/>
                    </ContextMenu>
                </DataGrid.ContextMenu>
                <DataGrid.Columns>
                    <DataGridTextColumn Header="ID"  Binding="{Binding ISharedStep.Id}" Width="*">
                        <DataGridTextColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTextColumn.HeaderStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Title" Binding="{Binding Title}" Width="6*">
                        <DataGridTextColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTextColumn.HeaderStyle>
                        <DataGridTextColumn.CellStyle>
                            <Style TargetType="DataGridCell">
                                <Setter Property="ToolTip" Value="{Binding StepsToolTip}" />
                            </Style>
                        </DataGridTextColumn.CellStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Priority" Binding="{Binding Priority}" Width="*">
                        <DataGridTextColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTextColumn.HeaderStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Assigned To" Binding="{Binding TeamFoundationIdentityName.DisplayName}" Width="2*">
                        <DataGridTextColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTextColumn.HeaderStyle>
                    </DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>

            <GridSplitter Width="5" ResizeDirection="Auto" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Grid.Row="1" Grid.RowSpan="2" Grid.Column="1"/>

            <ProgressBar Name="progressBarTestCases" Minimum="0" Maximum="1" Height="16" IsIndeterminate="True" Margin="0,0,0,16" Grid.Row="2" Grid.Column="2" Visibility="Hidden"/>

            <StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="2" Margin="10,0,0,30">
                <TextBlock Text="Shared Step Related Test Cases" Margin="10,15,0,28" Height="Auto" Width="Auto" FontWeight="Bold" HorizontalAlignment="Left" />
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="4*" />
                        <ColumnDefinition Width="2*" />
                    </Grid.ColumnDefinitions>
                    <TextBox x:Name="tbTestCaseTitleFilter" Text="{Binding InitialViewFiltersTestCases.TitleFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TabIndex="5" Margin="10,0,0,0" Height="25"
            			Grid.Column="0" GotFocus="tbTestCaseTitleFilter_GotFocus"  LostFocus="tbTestCaseTitleFilter_LostFocus"  KeyUp="tbTestCaseTitleFilter_KeyUp"/>
                    <TextBox x:Name="tbTestCaseSuiteFilter" Text="{Binding InitialViewFiltersTestCases.SuiteFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TabIndex="6" Margin="10,0,0,0" Height="25" 
            			Grid.Column="1" GotFocus="tbTestCaseSuiteFilter_GotFocus"  LostFocus="tbTestCaseSuiteFilter_LostFocus"  KeyUp="tbTestCaseSuiteFilter_KeyUp"/>
                </Grid>
            </StackPanel>
            <DataGrid ItemsSource="{Binding Path=ObservableTestCases}" AutoGenerateColumns="False" Name="dgTestCases" Grid.Row="2" Grid.Column="2" 
                      IsReadOnly="True" SelectionMode="Extended"  SelectionUnit="FullRow" TabIndex="5"
                       Margin="{StaticResource SplitRight}">
                <!--SelectedCellsChanged="dgTestCases_SelectedCellsChanged" PreviewMouseRightButtonDown="dgTestCases_PreviewMouseRightButtonDown"-->
                <!--<DataGrid.ContextMenu>
                    <ContextMenu>
                        <MenuItem Name="dgTestCaseContextItemEdit" Command="{x:Static local:TestCasesInitialView.EditCommand}" Header="Edit"/>
                    </ContextMenu>
                </DataGrid.ContextMenu>-->
                <DataGrid.ItemContainerStyle>
                    <Style TargetType="{x:Type DataGridRow}"  BasedOn="{StaticResource {x:Type DataGridRow}}">
                        <EventSetter Event="MouseDoubleClick" Handler="dgTestCases_MouseDoubleClick" />
                        <EventSetter Event="PreviewKeyDown" Handler="dgTestCases_PreviewKeyDown" />
                    </Style>
                </DataGrid.ItemContainerStyle>

                <DataGrid.Columns>
                    <!--<DataGridTextColumn Header="ID"  Binding="{Binding ITestCase.Id}" Width="0.6*">
                        <DataGridTextColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTextColumn.HeaderStyle>
                    </DataGridTextColumn>-->
                    <DataGridTextColumn Header="Title" Binding="{Binding Title}" Width="4*">
                        <DataGridTextColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTextColumn.HeaderStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Suite" Binding="{Binding ITestSuiteBase.Title}" Width="2*">
                        <DataGridTextColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTextColumn.HeaderStyle>
                    </DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>


            <StackPanel Orientation="Vertical" Grid.Row="3" Grid.ColumnSpan="3" Margin="10,30,0,30">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                    <Button Name="btnEdit" Content="_Edit" Margin="0,0,10,0" Height="30" Width="90" VerticalAlignment="Center" Click="btnEdit_Click"/>
                    <Button Name="btnDuplicate" Content="_Duplcate"  Margin="30,0,10,0" Height="30" Width="90" VerticalAlignment="Center" Click="btnDuplicate_Click"/>
                    <Button Name="btnNew" Content="_New"  Margin="30,0,10,0" Height="30" Width="90" VerticalAlignment="Center" Click="btnNew_Click"/>
                    <Button Name="btnFindReferences" Content="Find References"  Margin="30,0,10,0" Height="30" Width="Auto" VerticalAlignment="Center" Click="btnFindReferences_Click"/>
                    <Button Name="btnChangeTestCases" Content="Change Test Cases"  Margin="30,0,10,0" Height="30" Width="Auto" VerticalAlignment="Center" Click="btnChangeTestCases_Click"/>
                </StackPanel>
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="4">
                <TextBlock Text="Shared Steps Count:" Margin="10,0,10,30" Height="25" Width="Auto" FontWeight="Bold"/>
                <TextBlock Text="{Binding SharedStepsCount}" Margin="10,0,10,30" Height="25" Width="Auto" />
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="4" Grid.Column="2">
                <TextBlock Text="Test Case Count:" Margin="10,0,10,30" Height="25" Width="Auto" FontWeight="Bold"/>
                <TextBlock Name="tbTestCaseCount"  Text="{Binding TestCasesCount}" Margin="10,0,10,30" Height="25" Width="Auto" />
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
